import api from '@/services/merchant-account/merchant-user/user-management';

export type MerchantAccountUserManagement = MerchantAccountUserManagementApi.InfoResponse;
export type MerchantAccountUserManagementList = MerchantAccountUserManagementApi.ListResponse;
export const getFilterList = async () => {
  const res = await api.getFilterList();
  return res.data;
};
export const getList = async (params: MerchantAccountUserManagementApi.ListParams) => {
  const res = await api.getList<MerchantAccountUserManagementList>(params);
  const tableData: Requestor.TableFormatedData<MerchantAccountUserManagementList> = {
    data: res.listData,
    current: res.page + 1,
    pageSize: res.limit,
    total: res.count,
    success: res.success,
  };

  return tableData;
};

export const getInfo = async (params: MerchantAccountUserManagementApi.InfoParams) => {
  const res = await api.getInfo<MerchantAccountUserManagement>(params);
  return res.data;
};
export const create = async (params: MerchantAccountUserManagementApi.CreateParams) => {
  const data = await api.create(params);
  return data;
};
export const update = async (params: MerchantAccountUserManagementApi.UpdateParams) => {
  const data = await api.update(params);
  return data;
};
export const updateBind = async (params: MerchantAccountUserManagementApi.BindParams) => {
  const data = await api.updateBind(params);
  return data;
};

export const remove = async (params: MerchantAccountUserManagementApi.DeleteParams) => {
  const data = await api.remove(params);
  return data;
};

export default {
  getFilterList,
  getList,
  getInfo,
  create,
  update,
  updateBind,
  remove,
};
